package com.quanshu.exchange.ui.gui.message.chat.row.viewholder;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.hyphenate.chat.EMMessage;
import com.hyphenate.chat.EMVideoMessageBody;
import com.hyphenate.exceptions.HyphenateException;
import com.quanshu.exchange.R;
import com.quanshu.exchange.support.chat.ChatConstant;
import com.quanshu.exchange.ui.gui.message.chat.row.BaseChatRowViewHolder;
import com.quanshu.exchange.ui.gui.message.chat.row.ChatImageUtil;

// 发送视频消息ViewHolder
public class VideoSendViewHolder extends BaseChatRowViewHolder {
    ImageView image;

    public VideoSendViewHolder(Context context, View view) {
        super(context, view);
        image = view.findViewById(R.id.chat_video_img);
    }

    @Override
    public void setViewInfo(EMMessage chatMessage, EMMessage preMessage, String groupOwner) {
        super.setViewInfo(chatMessage, preMessage, groupOwner);
        EMVideoMessageBody videoBody = (EMVideoMessageBody) chatMessage.getBody();
        String localThumb = videoBody.getLocalThumb();

        ChatImageUtil.showToAllVideoView(localThumb, image, chatMessage, context);
        // 设置内容
        try {
            String reply = chatMessage.getStringAttribute(ChatConstant.Chat_reply_member);
            if (reply != null) {
                replyContent.setVisibility(View.VISIBLE);
                replyContent.setText("回复:" + reply);
            }
        } catch (HyphenateException e) {
            e.printStackTrace();
            replyContent.setVisibility(View.GONE);
        }
    }

}